package leetcode.string;

public class Leet686 {
    public static void main(String[] args) {
        int res = new Leet686().repeatedStringMatch("abcd", "cdabcdab");
        System.out.println(res);
    }

    public int repeatedStringMatch(String a, String b) {
        String temp = a;
        int index = 0;
        while (true) {
            if (temp.contains(b)) {
                return index;
            }
            temp += a;
            index++;
            if (temp.length() > b.length() + a.length()) {
                if (temp.contains(b)) {
                    return index;
                }
                return -1;
            }
        }

    }
}
